<include file="../Public/_header.html" />
<div class="so_main">
		  
		  <!-------- 搜索开始 -------->
		  <div id="search_div" rel='0'>
		  	<div class="page_tit">
		  		搜索货架[ <a href="javascript:void(0);" onclick="_show_searcharea();">隐藏</a> ]
		  	</div>
				
				<div class="sform">
					<form method="post" action="{:U('/Shelf/index')}" id="searchForm">
						<input id="pno" name="pno" type="hidden" value="1">
						<dl>
							<span>货架编号：</span>
					        <input name="shelf_id" type="text" value="{$shelf_id}">
					       	<span>价格范围：</span>
					        <input name='sprice' size="4" value='{$sprice}' type="text" style="width:65px">
              				&nbsp;-&nbsp;
              				<input name='bprice' size="4" value='{$bprice}' type="text" style="width:65px">
					       
					    	<php>if(!empty($goods_id))$partner_id=getParnterIdByGoodsId($goods_id);</php>
					      	<span>选择商户：</span>
					        <input id="partnerdesc" type="text" value="{:getParnterTitle($partner_id)}"
					        onclick="k_pop_syncSearch('partner_id'
					        													,'partnerdesc'
					        													,'选择商户'
					        													,'{:U('Admin://Partner/getJson')}'
					        													,function(){ $('#goodsdesc').click(); }
					        													,function(){ $('#goodsdesc').val('');$('#goods_id').val(''); })" 
					        readonly >
					        <input name="partner_id" id="partner_id" type="hidden" value="{$partner_id}">

					      	<span>选择商品：</span>
					        <input id="goodsdesc" type="text" value="{:getGoodsTitle($goods_id)}"
					        onclick="k_pop_syncSearch('goods_id'
					        													,'goodsdesc'
					        													,'选择商品'
					        													,'{:U('Admin://Goods/getJson',array('partner_id'=>''))}'+$('#partner_id').val()
					        													,null
					        													,null)" 
					        readonly >
					        <input name="goods_id" id="goods_id" type="hidden" value="{$goods_id}">
					      
							
							
					    </dl>	
					    <dl>
					    	<span>商户分类：</span>
						    	<input id="p_sortdesc" type="text" value="{$p_sort_id|getCategoryName}" 
					      					onclick="ui.box.load(
					    											'{:U('Index://Public/showtree',array('code'=>'partner','onclick'=>'p_tmp_setselectdict'))}'
					    											,{ title:'查看商户分类' })"
					      					readonly>
					      		<input id="p_sort_id" name="p_sort_id" type="hidden" value="{$p_sort_id}">
									<script>
											function p_tmp_setselectdict(rel,txt){
									    		$('#p_sortdesc').val(txt);
									    		$('#p_sort_id').val(rel);
									    }
									</script>
					      	<span>商品分类：</span>
					      
						    	<input id="g_sortdesc" type="text" value="{$g_sort_id|getCategoryName}" 
					      					onclick="ui.box.load(
					    											'{:U('Index://Public/showtree',array('code'=>'goods','onclick'=>'g_tmp_setselectdict'))}'
					    											,{ title:'查看商品分类' })"
					      					readonly>
					      	<input id="g_sort_id" name="g_sort_id" type="hidden" value="{$g_sort_id}">
									<script>
											function g_tmp_setselectdict(rel,txt){
									    		$('#g_sortdesc').val(txt);
									    		$('#g_sort_id').val(rel);
									    }
									</script>
							<span>商户有效：</span>
							&nbsp;&nbsp;
					      	<input name="p_enable" type="radio" value="all" <eq name="p_enable" value="all">checked</eq>>全部
					      	&nbsp;&nbsp;&nbsp;
					        <input name="p_enable" type="radio" value="Y" <eq name="p_enable" value="Y">checked</eq>>是
					        &nbsp;&nbsp;&nbsp;&nbsp;
					        <input name="p_enable" type="radio" value="N" <eq name="p_enable" value="N">checked</eq>>否
					        
							<span>商品有效：</span>
							&nbsp;&nbsp;
					      	<input name="g_enable" type="radio" value="all" <eq name="g_enable" value="all">checked</eq>>全部
					      	&nbsp;&nbsp;&nbsp;
					        <input name="g_enable" type="radio" value="Y" <eq name="g_enable" value="Y">checked</eq>>是
					        &nbsp;&nbsp;&nbsp;&nbsp;
					        <input name="g_enable" type="radio" value="N" <eq name="g_enable" value="N">checked</eq>>否
					        
					    </dl>
					    <dl>
					    	<span>货架状态：</span>
						    <input name="shelfstatus" type="radio" value="on" <eq name="shelfstatus" value="on">checked</eq>>已上架
						    &nbsp;&nbsp;
						    <input name="shelfstatus" type="radio" value="off" <eq name="shelfstatus" value="off">checked</eq>>已下架
						    &nbsp;&nbsp;
						    <input name="shelfstatus" type="radio" value="wait" <eq name="shelfstatus" value="wait">checked</eq>>待上架
						    
						    <span>排序方式：</span>
						    <input name="stype" type="radio" value="sale" <eq name="stype" value="sale">checked</eq>>畅销
						    &nbsp;&nbsp;
						    <input name="stype" type="radio" value="new" <eq name="stype" value="new">checked</eq>>最新
						    &nbsp;&nbsp;
						    <input name="stype" type="radio" value="down" <eq name="stype" value="down">checked</eq>>价格由高到低
						    &nbsp;&nbsp;
						    <input name="stype" type="radio" value="up" <eq name="stype" value="up">checked</eq>>价格由低到高
						</dl>
					    <dl>
					    	<input type="submit" class="btn_b" value="搜索" />
					    	&nbsp;&nbsp;&nbsp;&nbsp;
					    	<input type="reset" class="btn_b" value="清空" />
					    </dl>
					</form>
					<div class="clear"></div>
			  </div>
		  </div>
		  <!-------- 搜索结束 -------->
		  

  <div class="page_tit">货架管理</div>
  <div class="Toolbar_inbox">
  		<a href="javascript:void(0);" class="btn_a" onclick="_show_searcharea();">
			<span>条件搜索</span>
		</a>
    	<a href="javascript:void(0);" class="btn_a" onclick="del();"><span>删除上架商品</span></a>
  </div>
  
  <div class="list">
  <table id="goods_list" width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th style="width:30px;">
        <input type="checkbox" id="checkbox_handle" onclick="table_checkAll(this)" value="0">
        <label for="checkbox"></label>
    </th>
    <th class="line_l">ID</th>
    <th class="line_l" style="text-align:center"
    	 	title="户、品、架：对应商户、商品、上架，表示其各自是否有效。E代表对应数据为空。D代表对应数据已删除。">
    	 	户&nbsp;品&nbsp;架</th>
    <th class="line_l" style="text-align:center"
    		title="已售完：当进货量与卖出量相等，则表明该进货价商品已售完！销售中：当进货量与卖出量不相等，并且是否有效（enable=Y），表明该进货价的商品在销售中。暂停售：当进货量与卖出量不相等，并且是否有效（enable=N），表明该价格的进货暂时不能销售。"
    		>状态</th>
    <th class="line_l">商户</th>
    <th class="line_l">商品</th>
    <th class="line_l">分类</th>
    <th class="line_l" style="text-align:center">上架时间</th>
    <th class="line_l" style="text-align:center">下架时间</th>
    <th class="line_l" style="text-align:right">出售价</th>
    <th class="line_l" style="text-align:right">积分</th>
    <th class="line_l" style="text-align:right">已售</th>
    <th class="line_l" style="text-align:right">剩余</th>
    <th class="line_l" style="text-align:right">总数</th>
    <th class="line_l" style="text-align:center">操作</th>
  </tr>
  <volist id="vo" name="shelfpage['data']">
  	<php>$partner_id=getParnterIdByGoodsId($vo['goods_id']);
  			 $productdata = service('Product')->getByShelfId($vo['shelf_id']);
  			 $prodstatus = service('Product')->checkProductStatus($productdata);
  	</php>
      <tr overstyle='on' id="shelf_{$vo.shelf_id}">
        <td><input type="checkbox" name="checkbox" id="checkbox2" onclick="table_checkon(this)" value="{$vo.shelf_id}"></td>
        <td>{$vo.shelf_id}</td>
        <td style="text-align:center;padding: 6px 0 6px 0px;color:red">
        	{$prodstatus['p_status']}&nbsp;&nbsp;{$prodstatus['g_status']}&nbsp;&nbsp;{$prodstatus['s_status']}</td>
        
        <td style="text-align:center;padding: 6px 0 6px 0px;">
	        	<span <php>	if($prodstatus['isCanOn']){ echo "style='color:green'";}
	        							else	{
													if($prodstatus['isWaiting']){ echo "style='color:#AEB404'";}
													else { echo "style='color:red'";}
												}
									</php>
	        				 >
	        		{$prodstatus['desc']}
	        	</span>
        </td>
        
        <td>
	        	<a href="{:U('/Partner/index',array('parent_id'=>$partner_id))}" 
	        		id="price_title_{$vo.shelf_id}">{$vo['goods_id']|getParnterTitleByGoodsId}</a>
        </td>
        <td>
        	<a href="{:U('/Shelf/index',array('good_id'=>$vo['good_id']))}" >{$vo['goods_id']|getGoodsTitle}</a>
        </td>
 				
 		<td><a href="{:U('/Shelf/index',array('good_id'=>$vo['good_id']))}" >{$vo['goods_sort_id']|getCategoryName}</a></td>
		 		
		<td style="text-align:center">{:paramMillisecond2Date($vo['shelf_on_time'],'Y-m-d H:i', '未设置' )}</td>
		
		<td style="text-align:center">{:paramMillisecond2Date($vo['shelf_off_time'],'Y-m-d H:i', '未设置' )}</td>
		<td style="text-align:right">{$vo.shelf_out_price}</td>
		 		
		<td style="text-align:right">{$vo.shelf_gain_credit}</td>
		 		
		<td style="text-align:right">{$vo.shelf_send_number}</td>
 		<td style="text-align:right">
	        <span><php> echo $vo['shelf_total_number']-$vo['shelf_send_number'];</php></span>
        </td>
        <td style="text-align:right">
	        <span><php> echo $vo['shelf_total_number'];</php></span>
        </td>
        <td style="text-align:center">
            <a href="{:U('/Shelf/edit',array('shelf_id'=>$vo['shelf_id']))}" >编辑</a>&nbsp;
            <a href="javascript:void(0);" onclick="del({$vo['shelf_id']});">删除</a>&nbsp;
            <a href="javascript:void(0);" 
            		onclick="k_pop_goodsprice('{:U('Admin://Price/getAvailabePrice')}'
					        				,'{$vo['goods_id']}'
					        				,'商品 {$vo['goods_id']|getGoodsTitle} 当前价格');" title="查看当前价格">价格</a>&nbsp;
			<a href="{:U('/Order/index',array('search_shelfId'=>$vo['shelf_id']))}" title="查看所有订单">订单</a>
            
        </td>
      </tr>
  </volist>
  </table>

  </div>
  <div class="Toolbar_inbox">
    <div class="page_box">{$shelfpage['html']}</div>
  </div>
 
</div>

 <div class="clear"></div>

<script>
    //鼠标移动表格效果
    $(document).ready(function(){
    	table_init();
    });
    
    //删除分类
    function del(aid) {
        aid = aid ? aid : getChecked();
        aid = aid.toString();
        if(aid == '') return false;
		if(!confirm('确定删除么？')){
				return;
		}
        //提交删除
        $.post("{:U('/Shelf/doPutoff')}", {ids:aid}, function(res){
	        if(res == '1') {
		        aid = aid.split(',');
		        $.each(aid, function(i,n){
		            $('#partner_'+n).remove();
		        });
	            ui.success('删除成功');
	        }else {
	        	ui.success('删除失败');
	        }
        });
        
        
    }
</script>

<include file="../Public/_footer.html" />